package com.tool.btn;

import java.awt.event.MouseEvent;

import javax.swing.SwingConstants;

import org.come.Frame.RaceChangeMainJframe;
import org.come.Jpanel.RaceChangeMainJpanel;
import org.come.until.CutButtonImage;

import com.tool.tcpimg.UIUtils;



public class RoleMetemBtn extends MoBanBtn {

	private RaceChangeMainJpanel roleMetempsychosisJpanel;
	private int caozuo;

	public RoleMetemBtn(String iconpath, int type, int caozuo, RaceChangeMainJpanel roleMetempsychosisJpanel) {
		super(iconpath, type);
		this.caozuo = caozuo;
		this.roleMetempsychosisJpanel = roleMetempsychosisJpanel;
		setHorizontalTextPosition(SwingConstants.CENTER);
		setVerticalTextPosition(SwingConstants.CENTER);
	}

	public RoleMetemBtn(String iconpath, int type, String text, int caozuo,
						RaceChangeMainJpanel roleMetempsychosisJpanel) {
		super(iconpath, type);
		this.caozuo = caozuo;
		this.roleMetempsychosisJpanel = roleMetempsychosisJpanel;
		setText(text);
		setFont(UIUtils.TEXT_HY16);
		setHorizontalTextPosition(SwingConstants.CENTER);
		setVerticalTextPosition(SwingConstants.CENTER);
	}

	@Override
	public void chooseyes() {
		// TODO Auto-generated method stub

	}

	@Override
	public void chooseno() {
		// TODO Auto-generated method stub

	}

	@Override
	public void nochoose(MouseEvent e) {
		// TODO Auto-generated method stub
		RaceChangeMainJpanel raceChangeMainJpanel = RaceChangeMainJframe.getRaceChangeMainJframe()
				.getRaceChangeMainJpanel();
		switch (caozuo) {
			case 1:
				if (raceChangeMainJpanel.getRoleType() != 1 && raceChangeMainJpanel.getRoleType() != 2) {
					raceChangeMainJpanel.setRoleType(1);
					raceChangeMainJpanel.changSexNames();
				}
				changMenu(194);
				break;
			case 2:
				if (raceChangeMainJpanel.getRoleType() != 3 && raceChangeMainJpanel.getRoleType() != 4) {
					raceChangeMainJpanel.setRoleType(3);
					raceChangeMainJpanel.changSexNames();
				}
				changMenu(192);
				break;
			case 3:
				if (raceChangeMainJpanel.getRoleType() != 5 && raceChangeMainJpanel.getRoleType() != 6) {
					raceChangeMainJpanel.setRoleType(5);
					raceChangeMainJpanel.changSexNames();
				}
				changMenu(196);

				break;
			case 4:
				if (raceChangeMainJpanel.getRoleType() != 7 && raceChangeMainJpanel.getRoleType() != 8) {
					raceChangeMainJpanel.setRoleType(7);
					raceChangeMainJpanel.changSexNames();
				}
				changMenu(188);
				break;
			case 5:
				if (raceChangeMainJpanel.getRoleType() != 9 && raceChangeMainJpanel.getRoleType() != 10) {
					raceChangeMainJpanel.setRoleType(9);
					raceChangeMainJpanel.changSexNames();
				}
				changMenu(190);
				break;
			default:
				break;
		}

		raceChangeMainJpanel.reloadRace(raceChangeMainJpanel.getRoleType(), raceChangeMainJpanel.getNumber());
	}

	public void changMenu(int type) {
		try {
			for(int i = 0; i < this.roleMetempsychosisJpanel.getMenuBtn().length; ++i) {
				if (i + 1 == this.caozuo) {
					this.roleMetempsychosisJpanel.getMenuBtn()[i].setIcons(CutButtonImage.cuts("skin/8100226/newbutton/K86"+(this.roleMetempsychosisJpanel.getMenuName()[i])+".png"));
				} else {
					this.roleMetempsychosisJpanel.getMenuBtn()[i].setIcons(CutButtonImage.cuts("skin/8100226/newbutton/K85"+(this.roleMetempsychosisJpanel.getMenuName()[i])+".png"));
				}
			}
		} catch (Exception e) {
			e.printStackTrace();
		}
	}
}
